Repository Public MIT
1import type { Metadata } from "next";2import { notFound, permanentRedirect } from "next/navigation";3import { SessionBody } from "@/components/session/SessionBody";4import { getCourse, getRedirects, getSession } from "@/lib/content";5import { pageMeta } from "@/lib/seo";6import { sessionPath } from "@/modules/content-schema";78export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }): Promise<Metadata> {9 const session = await getSession((await params).slug);10 if (!session) return {};11 const state = session.access === "open" ? "" : session.access === "archived" ? " Séance archivée." : " Séance à venir.";12 return pageMeta({ title: `Séance ${session.number} — ${session.title}`, description: `${session.outcomes[0] ?? session.title}${state}`.slice(0, 300), path: sessionPath(session.slug), index: session.access !== "archived" });13}1415export default async function SessionPage({ params }: { params: Promise<{ slug: string }> }) {16 const [course, { slug }] = await Promise.all([getCourse(), params]);17 const session = course.sessions.find((s) => s.slug === slug);18 if (!session) {19 // A former address of a session answers with a permanent redirect to the current one.20 const current = (await getRedirects()).aliases.get(slug);21 if (current) permanentRedirect(sessionPath(current));22 notFound();23 }24 return <SessionBody course={course} session={session} />;25}26